﻿using System.Collections.Generic;
using UnityEngine;

namespace HEFramework
{
    /// <summary>
    /// 全局唯一
    /// </summary>
    public class Draw : MonoBehaviour
    {
        public struct Circle
        {
            public Vector3 Pos { get; set; }
            public float Radius { get; set; }
            public Color Color { get; set; }
        }

        public readonly List<Circle> Circles = new();

#if UNITY_EDITOR
        private void OnDrawGizmos()
        {
            DrawPendingGizmos();
        }
        
     

        private void DrawPendingGizmos()
        {
            foreach (var circle in Circles)
            {
                UnityEditor.Handles.color = circle.Color;
                UnityEditor.Handles.SphereHandleCap(0, circle.Pos, Quaternion.identity, circle.Radius, EventType.Repaint);
            }

            Circles.Clear(); // 清除已绘制的图形，以便下次重绘
        }
        
#endif
    }

    public class DebugDraw : Entity, IAwake
    {
        public string Tag { get; set; } = "DebugDraw";
        public Draw Draw { get; set; }
    }
}